package jaux.tank.generator.util;

import java.awt.Component;
import java.util.ResourceBundle;

import javax.swing.JOptionPane;

public class MessageUtil {
	
	

	private MessageUtil( ) {
	}
	
	public static  void showError(Component parent, String message, Object... args) {
		JOptionPane.showMessageDialog(parent, formatMessage(message, args), TextUtil.getInstance().getString("common.error"), JOptionPane.ERROR_MESSAGE);
	}
	
	public static  void showInfo(Component parent, String message, Object... args) {
		JOptionPane.showMessageDialog(parent, formatMessage(message, args),  TextUtil.getInstance().getString("common.info"), JOptionPane.INFORMATION_MESSAGE);
	}
	
	public static  void showWarning(Component parent, String message, Object... args) {
		JOptionPane.showMessageDialog(parent, formatMessage(message, args),  TextUtil.getInstance().getString("common.warning"), JOptionPane.WARNING_MESSAGE);
	}
	
	public static  boolean isYes(Component parent, String message, Object... args) {
		return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(parent, formatMessage(message, args),  TextUtil.getInstance().getString("common.confirm"), JOptionPane.YES_NO_OPTION);
	}
	
	public static  String getInput(Component parent, String message, Object... args) {
		return JOptionPane.showInputDialog(parent, formatMessage(message, args));
	}

	private static String formatMessage(String message, Object... args) {
		return  String.format(message,  args);
	}
}
